# MyMath类静态方法
class MyMath:
    @staticmethod
    def add(a, b):
        return a + b

    @staticmethod
    def minus(a, b):
        return a - b

    @staticmethod
    def mul(a, b):
        return a * b

    @staticmethod
    def div(a, b):
        return a / b

    @staticmethod
    def root(a):
        return a ** (1 / 2)

print(MyMath.add(1, 2))
print(MyMath.minus(4, 3))
print(MyMath.mul(2, 4))
print(MyMath.div(6, 3))
print(MyMath.root(9))


# 自定义类
class Worker:
    # 类属性
    profession = 'Internet'
    # 私有属性
    __firm = 'hehe'
    # init类初始化实例属性、绑定私有实例属性
    def __init__(self, name = None):
        self.__name = name
    # 自定义类中实现__str__自定义输出格式
    @classmethod
    def __str__(cls, *args, **kwargs):
        print(f"员工从事行业为{cls.profession}，公司名为{cls.__firm}")
        return None


w = Worker()
print(w._Worker__name)

a = Worker('Alice')
print(a._Worker__name)
a.__str__()

